package com.bilgeadam.hibernate.model.bll;

import java.util.List;

import com.bilgeadam.hibernate.model.dal.AbstractDal;
import com.bilgeadam.hibernate.model.entity.EntityBase;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 16, 2014 5:42:40 PM
 * @version 1.0.0
 */
public abstract class AbstractBll<T, E extends EntityBase<T>> implements GenericBll<T, E> {

	private final AbstractDal<T, E> dal;

	public AbstractBll(AbstractDal<T, E> dal) {
		this.dal = dal;
	}

	public E findById(T id) {
		return dal.findById(id);
	}

	public List<E> getAll() {
		return dal.getAll();
	}

	public boolean add(E e) {
		boolean result = false;
		if (validateEntity(e)) {
			dal.add(e);
			result = true;
		}
		return result;
	}

	public boolean delete(E e) {
		return dal.delete(e);
	}

	public boolean update(E e) {
		boolean result = false;
		if (validateEntity(e)) {
			dal.update(e);
			result = true;
		}
		return result;
	}

}
